3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next

Draw Contexts

Although a drawing engine may be capable of supporting more than one device, it cannot divide a raster across multiple devices. Instead, every drawing command sent to a drawing engine must be destined for a single device. QuickDraw 3D RAVE guarantees this by requiring a calling application to specify a draw context as a parameter for every drawing command. A draw context is a structure (of type TQADrawContext ) that maintains state information and other data associated with a particular drawing engine and device.

As mentioned at the end of the previous section, you need to create several draw contexts if you want to draw into a window that spans several devices. Similarly, you need to create several draw contexts if you want to draw into several different windows on the same device. Each draw context maintains its own state information image buffers and is unaffected by any functions that operate on another draw context.

The state information associated with a draw context is maintained using a large number of state variables. For example, the background color of a draw context is specified by four state variables, designated by the four identifiers (or tags ) kQATag_ColorBG_a , kQATag_ColorBG_r , kQATag_ColorBG_g , and kQATag_ColorBG_b . See "Creating and Configuring a Draw Context" , for some sample code that reads and sets state variables, and "Tags for State Variables" , for a complete list of the available state variables.

A hardware device (such as a frame buffer or a video interface) is represented in QuickDraw 3D RAVE by a virtual device, a structure of type TQADevice that determines which one of a variety of types of hardware devices a draw context draws into. On Macintosh computers, QuickDraw 3D RAVE supports two kinds of virtual devices: memory devices and graphics devices. A memory device represents an area of memory, and a graphics device represents a video device (such as a plug-in video card or built-in video interface) that controls a screen, or an offscreen graphics world (which allows your application to build complex images off the screen before displaying them). In effect, a virtual device specifies the buffers into which all drawing commands associated with a draw context write pixels.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next